<?
$JO[ "Unit"				] = JO( array( "EN" => "Unit",				"KO" => "ì•„í‹°ìŠ¤íŠ¸",	"VI" => "Đơn Vị"		) );
$JO[ "Content"			] = JO( array( "EN" => "Content",			"KO" => "ì•„í‹°ìŠ¤íŠ¸",	"VI" => "Nội Dung"		) );
$JO[ "Subject"			] = JO( array( "EN" => "Subject",			"KO" => "ì•„í‹°ìŠ¤íŠ¸",	"VI" => "Tựa Đề"		) );
$JO[ "Image"			] = JO( array( "EN" => "Image",				"KO" => "ì•„í‹°ìŠ¤íŠ¸",	"VI" => "Hình Ảnh"		) );
$JO[ "Insert"			] = JO( array( "EN" => "Insert",			"KO" => "ì•„í‹°ìŠ¤íŠ¸",	"VI" => "Nhập"		) );
$JO[ "InsertIndex"		] = JO( array( "EN" => "Insert a Index",	"KO" => "ì•„í‹°ìŠ¤íŠ¸",	"VI" => "Nhập Index"		) );
$JO[ "Delete"			] = JO( array( "EN" => "Delete",			"KO" => "ì•„í‹°ìŠ¤íŠ¸",	"VI" => "Xóa"		) );
$JO[ "InsertContent"	] = JO( array( "EN" => "Insert a Content",	"KO" => "ì•„í‹°ìŠ¤íŠ¸",	"VI" => "Nhập Công Việc"		) );
$JO[ "IndexList"		] = JO( array( "EN" => "Index List", 		"KO" => "ì•„í‹°ìŠ¤íŠ¸",	"VI" => "Danh Sách Index"		) );
$JO[ "Key"				] = JO( array( "EN" => "Key", 				"KO" => "ì•„í‹°ìŠ¤íŠ¸",	"VI" => "Mã Số"		) );
$JO[ "Operator"			] = JO( array( "EN" => "Operator",			"KO" => "ì•„í‹°ìŠ¤íŠ¸",	"VI" => "Người Điều Hành"		) );
$JO[ "Link"				] = JO( array( "EN" => "Link", 				"KO" => "ì•„í‹°ìŠ¤íŠ¸",	"VI" => "Đường Dẫn"		) );
$JO[ "Update"			] = JO( array( "EN" => "Update", 			"KO" => "ì•„í‹°ìŠ¤íŠ¸",	"VI" => "Cập Nhật"		) );
$JO[ "UpdateIndex"		] = JO( array( "EN" => "Update a Index", 	"KO" => "ì•„í‹°ìŠ¤íŠ¸",	"VI" => "Cập Nhật Index"		) );

?>
<div class="JO_left">



	<?

		if( $_REQUEST[ "SO_index_key" ] ) {

			$query = "
				SELECT	*
				FROM	`index`
				WHERE	`key` = '" . $_REQUEST[ "SO_index_key" ] . "'
			";

			$recordSet = JO_query( $query );

			if( $recordSet -> num_rows ) $record = $recordSet -> fetch_array( );

		}

	?>



	<!-- Form -->

		<form
			action	= "JO_71_SO/SO_05_execution.php"
			target	= "JO_integration_asynchronous"
			method	= "post"
			class	= "JO_bar_720"
		>

			<input type="hidden" name="SO_query"		value="index_<?= empty( $_REQUEST[ "SO_index_key" ] ) ? "insert" : "update" ?>"	/>
			<input type="hidden" name="SO_index_key"	value="<?= $_REQUEST[ "SO_index_key" ] ?>"										/>

			<h1><?= empty( $_REQUEST[ "SO_index_key" ] ) ? $JO[ "InsertIndex" ] : $JO[ "UpdateIndex" ] ?></h1>

			<div>

				<table>

					<tr>
						<th style="width: 81px;"><?=$JO[ "Unit"	]?></th>
						<td>

							<select name="SO_index_unit" style="width: 584px;">

								<option>																		</option> <!-- non publishment -->
								<option <?= $record[ "unit" ] == "promotion"	? "selected" : "" ?>>promotion	</option>
								<option <?= $record[ "unit" ] == "notice"		? "selected" : "" ?>>notice		</option>
								<option <?= $record[ "unit" ] == "magazine"		? "selected" : "" ?>>magazine	</option>
								<option <?= $record[ "unit" ] == "vote"			? "selected" : "" ?>>vote		</option>
								<option <?= $record[ "unit" ] == "beta"			? "selected" : "" ?>>beta		</option>

							</select> 

						</td>
					</tr>

					<tr>
						<th><?=$JO[ "Subject" ]?></th>
						<td>

							<input
								type	= "text"
								name	= "SO_index_subject"
								value	= "<?= $record[ "subject" ] ?>"
								style	= "width: <?= $JO_MSIE ? 569 : 571 ?>px;"
							 />

						</td>
					</tr>

					<tr>
						<th style="padding-top: 12px; vertical-align: top;">Content</th>
						<td>

							<textarea
								name	= "SO_index_content"
								style	= "width: 567px; height: <?= substr_count( $record[ "content" ], "\r\n" ) ? substr_count( $record[ "content" ], "\r\n" ) * 16 : 16 ?>px;"
								onkeyup	= "this.style.height = ( this.value.split( '\n' ).length * 16 ) + 'px'";"
							><?= $record[ "content" ] ?></textarea>

						</td>
					</tr>

					<tr>
						<th>Mark</th>
						<td>

							<input
								type	= "text"
								name	= "SO_index_mark"
								value	= "<?= $record[ "mark" ] ?>"
								style	= "width: <?= $JO_MSIE ? 569 : 571 ?>px;"
							 />

						</td>
					</tr>

					<tr>
						<th><?=$JO[ "Image"	]?></th>
						<td>

							<input
								type	= "text"
								name	= "SO_index_image"
								value	= "<?= $record[ "image" ] ?>"
								style	= "width: <?= $JO_MSIE ? 569 : 571 ?>px;"
							 />

						</td>
					</tr>

					<tr>
						<th><?=$JO[ "Link"	]?></th>
						<td>

							<input
								type	= "text"
								name	= "SO_index_link"
								value	= "<?= $record[ "link" ] ?>"
								style	= "width: <?= $JO_MSIE ? 569 : 571 ?>px;"
							 />

						</td>
					</tr>

					<tr>
						<th><?=$JO[ "Insert"	]?></th>
						<td>

							<input
								type	= "text"
								name	= "SO_index_insert"
								value	= "<?= $record[ "insert" ] ?>"
								style	= "width: <?= $JO_MSIE ? 569 : 571 ?>px;"
							 />

						</td>
					</tr>

					<tr>
						<th><?=$JO[ "Delete"	]?></th>
						<td>

							<input
								type	= "text"
								name	= "SO_index_delete"
								value	= "<?= $record[ "delete" ] ?>"
								style	= "width: <?= $JO_MSIE ? 569 : 571 ?>px;"
							 />

						</td>
					</tr>

					<tr>
						<th style	= "border-bottom: 1px solid #FFFFFF; background-color: #FFFFFF;"></th>
						<td style	= "border-bottom: 1px solid #FFFFFF; background-color: #FFFFFF;">

							<input
								type	= "submit"
								value	= "<?= empty( $_REQUEST[ "SO_index_key" ] ) ? $JO[ "InsertIndex"	] : $JO[ "UpdateIndex"		] ?>"
								class	= "JO_button"
								style	= "width: 584px;"
							/>

						</td>
					</tr>

				</table>

			</div>



		</form>



	<!-- List -->

		<div class="JO_bar_720">

			<h1><?=$JO[ "IndexList"	]?></h1>

			<div>



				<table style="margin: 2px 3px 1px -3px;">

					<tr>
						<th style="width: 49px;"><?=$JO[ "Key"	]?>		</th>
						<th style="width: 65px;"><?=$JO[ "Unit"	]?>		</th>
						<th						><?=$JO[ "Subject"	]?>	</th>
						<th style="width: 89px;"><?=$JO[ "Insert"	]?>	</th>
						<th style="width: 89px;"><?=$JO[ "Update"	]?>	</th>

					</tr>

					<?

						$query = "
							SELECT		*
							FROM		`index`
							WHERE		`delete` IS NULL
							ORDER BY	`key` DESC
						";

						$recordSet = JO_query( $query );

						if( $recordSet -> num_rows ) while( $record = $recordSet -> fetch_array( ) ) {

					?>

						<tr>

							<td class="JO_right"><?= $record[ "key" ] ?></td>

							<td><?= $record[ "unit" ] ?></td>

							<td><a href="?SO_unit=11_index&SO_index_key=<?= $record[ "key" ] ?>"><?= $record[ "subject"	] ?></a></td>

							<td><?= substr( $record[ "insert" ], 0, 16 ) ?></td>

							<td><?= substr( $record[ "update" ], 0, 16 ) ?></td>

						</tr>

					<? } ?>

				</table>



			</div>

		</div>



</div>
